/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-03-20 16:32:52
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-03-29 10:46:01
 * @FilePath: \phoenix-client-damo\assets\src\phoenix\defines\error.define.ts
 * @Description: 
 */
export enum ErrorCode {
    UNKNOWN_ERROR = 10000,
    ACCOUNT_ERROR ,
    ACCOUNT_PASSWORD,
    ACCOUNT_NOT_FOUND,
    TOKEN_NULL,
    TOKEN_INVALID,
    TOKEN_ILLEGAL,
    AVATAR_ALREADY_EXIST,
    AVATAR_NOT_FOUND,
    REQUEST_PARAM_SIGNATURE,
    REQUEST_PARAM_TIME,
    PLATFORM_LOGIN_FAILED,
}

export enum ErrorCodeDescription {
    UNKNOWN_ERROR = '未知错误',
    ACCOUNT_ERROR = '账号错误',
    ACCOUNT_PASSWORD = '密码错误',
    ACCOUNT_NOT_FOUND = '账号不存在',
    TOKEN_NULL = 'token为空',
    TOKEN_INVALID = 'token无效',
    TOKEN_ILLEGAL = 'token非法',
    AVATAR_ALREADY_EXIST = '角色已存在',
    AVATAR_NOT_FOUND = '角色不存在',
    REQUEST_PARAM_SIGNATURE = '请求参数签名错误',
    REQUEST_PARAM_TIME = '请求参数时间错误',
    PLATFORM_LOGIN_FAILED = '平台登录失败',
}

export function makeError(errorCode: ErrorCode, errorDescription?: ErrorCodeDescription): object {
    return {"message": errorDescription, "code": errorCode};
}

export function getErrorDescription(errorCode: ErrorCode): ErrorCodeDescription {
    switch (errorCode) {
        case ErrorCode.ACCOUNT_ERROR:
            return ErrorCodeDescription.ACCOUNT_ERROR;
        case ErrorCode.ACCOUNT_PASSWORD:
            return ErrorCodeDescription.ACCOUNT_PASSWORD;
        case ErrorCode.ACCOUNT_NOT_FOUND:
            return ErrorCodeDescription.ACCOUNT_NOT_FOUND;
        case ErrorCode.TOKEN_NULL:
            return ErrorCodeDescription.TOKEN_NULL;
        case ErrorCode.TOKEN_INVALID:
            return ErrorCodeDescription.TOKEN_INVALID;  
        case ErrorCode.TOKEN_ILLEGAL:
            return ErrorCodeDescription.TOKEN_ILLEGAL;     
        case ErrorCode.AVATAR_ALREADY_EXIST:
            return ErrorCodeDescription.AVATAR_ALREADY_EXIST;      
        case ErrorCode.AVATAR_NOT_FOUND:
            return ErrorCodeDescription.AVATAR_NOT_FOUND;  
        case ErrorCode.REQUEST_PARAM_SIGNATURE:
            return ErrorCodeDescription.REQUEST_PARAM_SIGNATURE;      
        case ErrorCode.REQUEST_PARAM_TIME:
            return ErrorCodeDescription.REQUEST_PARAM_TIME;  
        case ErrorCode.PLATFORM_LOGIN_FAILED:
            return ErrorCodeDescription.PLATFORM_LOGIN_FAILED;              
        default:
            return ErrorCodeDescription.ACCOUNT_ERROR;
    }
}
